package com.sid.oncf.dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import com.sid.oncf.dao.interfaces.IRoleDao;
import com.sid.oncf.entity.Roles;

public class RoleDaoImpl implements IRoleDao {

	@PersistenceContext
	private EntityManager em;
	
	public boolean save(Roles r) {
		em.persist(r);
		return true;
	}

	public boolean delete(int id) {
		em.remove(find(id));
		return true;
	}

	public List<Roles> findAll() {
		Query query=em.createQuery("select r from Roles r",Roles.class);
		return query.getResultList();
	}

	public Roles find(int id) {
		return em.find(Roles.class,id);
	}

}
